-- Create User
create table [User]
(
	Id int identity(1,1) primary key,			    
	UserName nvarchar(250) not null,
	Salt nvarchar(500) not null,
	Password nvarchar(500) not null,
	Email nvarchar(250) not null,
	CreateTime datetime not null,
	CultureName nvarchar(10)
)
go

-- Create Website
create table [Website]
(
	Id int identity(1,1) primary key,			    
	Name nvarchar(250) not null,
	Url nvarchar(500) not null,
	PhysicalPath nvarchar(500) not null,
	CreateTime datetime not null,
	IsOnline bit not null,
	IsDeleted bit not null
)
go

-- Create PageType
create table [PageType]
(
	Id int identity(1,1) primary key,			    
	Name nvarchar(250) not null,
	WebsiteId int foreign key references Website(Id) not null,
	TemplatePath nvarchar(500) not null,
	CreateTime datetime not null,
	ExtensionForms nvarchar(max) null
)
go

-- Create Module
create table [Module]
(
	Id int identity(1,1) primary key,			    
	WebsiteId int foreign key references Website(Id) not null,
	Title nvarchar(250) not null,
	Content nvarchar(max),
	ExtensionValue nvarchar(max),
	ParentId int foreign key references Module(Id) null,
	CreateTime datetime not null,
	PublishTime datetime not null,
	IsDeleted bit not null,
	IsPublished bit not null,
	Url nvarchar(250) not null,
	ImagePath nvarchar(250) null,
	PageTypeId int foreign key references PageType(Id) not null,
	DefaultPageTypeId int foreign key references PageType(Id) null
)
go

-- Create ModuleImage
create table [ModuleImage]
(
	Id int identity(1,1) primary key,			    
	Name nvarchar(250) null,
	Path nvarchar(250) not null,
	ModuleId int foreign key references Module(Id) not null,
	Description nvarchar(max) null
)
go

-- Create Page
create table [Page]
(
	Id int identity(1,1) primary key,			    
	WebsiteId int foreign key references Website(Id) not null,
	Title nvarchar(250) not null,
	Content nvarchar(max),
	ExtensionValue nvarchar(max),
	ModuleId int foreign key references Module(Id) null,
	CreateTime datetime not null,
	PublishTime datetime not null,
	IsDeleted bit not null,
	IsPublished bit not null,
	Url nvarchar(250) not null,
	ImagePath nvarchar(250) null,
	PageTypeId int foreign key references PageType(Id) not null
)
go

-- Create PageImage
create table [PageImage]
(
	Id int identity(1,1) primary key,			    
	Name nvarchar(250) null,
	Path nvarchar(250) not null,
	PageId int foreign key references Page(Id) not null,
	Description nvarchar(max) null
)
go




